﻿@{
    ViewBag.Title = "DatasForm";
    Layout = "~/Views/Shared/_FlowForm.cshtml";
}
<style>
    .addclassify a {
        height: 22px;
        line-height: 22px;
        cursor: pointer;
        padding: 5px 10px;
        border-radius: 5px;
        text-decoration: none;
    }
    .addclassify a i {
        margin-right: 4px;
       color: rgb(92, 184, 92);
    }

    ul.classify {
        list-style: none;
    }
    ul.classify li {
            height: 30px;
            line-height: 30px;
            margin-bottom: 2px;
            overflow: hidden;
            padding: 0px 4px;
            background: rgb(244, 244, 244);
        }
   ul.classify li span {
        float: right;
    }
  ul.classify li span i {
        color: rgb(207, 92, 96);
        cursor: pointer;
        margin: -2px 3px 0px 0px;
    }
  ul.classify li span em {
        float: left;
        width: 18px;
        height: 18px;
        cursor: pointer;
        margin: 6px 10px 0px 0px;
        border-radius: 5px;
    }
  em.color_a {
        color: rgb(51, 122, 183);
        background-color: rgb(51, 122, 183);
        border-width: 1px;
        border-style: solid;
        border-color: rgb(51, 122, 183);
        border-image: initial;
    }
     ul.classify li .dragitem {
        -webkit-text-stroke-width: 0.22px;
        top: 3px;
        color: rgb(204, 204, 204);
        cursor: move;
        margin: 0px;
    }
     ul.classify li input[type="checkbox"] {
        vertical-align: middle;
        margin: -1px 5px 0px 6px;
        padding: 0px;
    }
     ul.classify li input[type="text"] {
        box-shadow: none;
        line-height: 15px;
        width: 115px;
        background: 0px 0px;
        border-width: initial;
        border-style: none;
        border-color: initial;
        border-image: initial;
        padding: 6px;
        outline: 0px;
    }
</style>
<script>
    var _Type = ""; var keyValue = request('keyValue');
    $(function () {
         initControl(); 
       // SetProperty();
    })
    function initControl() {
        //类别
        $("#Type").ComboBoxTree({
            url: "../../ResourceManage/RS_DeviceType/GetTreeJson",
            description: "==请选择==",
            height: "230px",
            click: function (item) {
                _Type = item.id;
            }
        });
        //参数类型
        $("#ValueType").ComboBox({
            data: [{ "key": "text", "value": "文本" }, { "key": "number", "value": "数值" }],
                id: "key",
                text: "value",
                description: "==请选择=="
        });
        $("#ValueType").ComboBoxSetValue("text");
        //数据来源类型
        $("#DataSourceType").ComboBox({
            data: [{ "key": 1, "value": "录入" }, { "key": 2, "value": "统计" }, { "key": 3, "value": "词典" }],
            id: "key",
            text: "value",
            description: "==请选择=="
        });
        $("#DataSourceType").ComboBoxSetValue(1);


        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_DeviceType/GetDatasFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    
                    $("#form1").SetWebControls(data);
                    $("#Type").ComboBoxTreeSetValue(data.Type);
                    $("#ValueType").ComboBoxSetValue(data.ValueType);
                    $("#DataSourceType").ComboBoxSetValue(data.DataSourceType);
                }
            });
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        postData["Required"] = $('#Required input[name="Required"]:checked ').val();
        
        $.SaveForm({
            url: "../../ResourceManage/RS_DeviceType/SaveDatasForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable2").trigger("reloadGrid");
            }
        })
    }
  </script>
<div style="margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <th class="formTitle">设备类别<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="Type" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
            <th class="formTitle">参数名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="Name" type="text" class="form-control" placeholder="请输入参数名称" isvalid="yes" checkexpession="NotNull" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">参数标准</th>
            <td class="formValue">
                <input id="Criterition" class="form-control" />
            </td>
            <th class="formTitle">参数值类型<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="ValueType" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">参数默认值</th>
            <td class="formValue">
                <input id="DefaultValue" type="text" class="form-control" />
            </td>
            <th class="formTitle">数据来源类型<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="DataSourceType" type="selectTree" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">数据来源</th>
            <td class="formValue">
                <input id="DataSourceId" type="text" class="form-control" />
            </td>
            <th class="formTitle">参数标准值</th>
            <td class="formValue">
                <input id="Value" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">排序</th>
            <td class="formValue">
                <input id="SortCode" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">是否必填<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="Required" class="radio">
                    <label><input name="Required" type="radio" value="0" checked="checked" />必填</label>
                    <label> <input name="Required" type="radio" value="1" />不必填</label>
                </div>
            </td>
        </tr>       
    </table>
</div>
